from django.core.management.base import BaseCommand
from users.models import User

class Command(BaseCommand):
    help = '创建超级管理员用户'

    def handle(self, *args, **options):
        if not User.objects.filter(username='admin').exists():
            User.objects.create_superuser(
                username='admin',
                email='admin@example.com',
                password='admin123',
                role='admin',
                phone='13800138000',
                company_name='系统管理',
            )
            self.stdout.write(self.style.SUCCESS('成功创建超级管理员用户'))
        else:
            self.stdout.write(self.style.WARNING('超级管理员用户已存在')) 